from django.db.utils import IntegrityError
from django.test import TestCase

from core import models


class ModelsTestCase(TestCase):
    def test_unicode_range_raises_integrity_error_with_empty_end(self):
        kwargs = {
            'start': '0000'
        }

        models.UnicodeRange.objects.create(**kwargs)

        self.assertRaises(
            IntegrityError,
            models.UnicodeRange.objects.create,
            **kwargs
        )

    def test_unicode_range_raises_integrity_error_with_filled_end(self):
        kwargs = {
            'start': '0000',
            'end': '1111'
        }

        models.UnicodeRange.objects.create(**kwargs)

        self.assertRaises(
            IntegrityError,
            models.UnicodeRange.objects.create,
            **kwargs
        )
